<?php
// +----------------------------------------------------------------------
// | Copyright © Sogu Technologies Co. Ltd 2018-2050 All rights reserved.
// +----------------------------------------------------------------------
// | File name: LoanVirement.php
// +----------------------------------------------------------------------
// | Author: gxs
// +----------------------------------------------------------------------
// | Description: 用于详细说明此程序文件完成的主要功能，与其他模块或函数的接口、输出值、取值范围、含义及参数间的控制、顺序或依赖等关系。
// +----------------------------------------------------------------------
// | Others: 其他内容的说明
// +----------------------------------------------------------------------
// | History: 修改历史记录列表，每条修改记录应包含修改日期、修改者及修改内容简述
// +----------------------------------------------------------------------
// | 1.Date: 2019/2/28 Author: gxs Modification: 创建
// +----------------------------------------------------------------------

namespace App\ModelTransfers\WsLoans;

use App\ModelTransfers\Base;

class LoanVirement extends Base
{
    //原卡贷还款状态
    //0初始化,1处理中,2成功 ,3 失败
    const VIREMENT_STATUS_ZERO = 0;
    const VIREMENT_STATUS_ONE = 1;
    const VIREMENT_STATUS_TWO = 2;
    const VIREMENT_STATUS_THREE = 3;

    //原卡贷扣款类型
    const SETTLE_TYPE_ZERO = 0; //结清
    const SETTLE_TYPE_ONE = 1; //手动
    const SETTLE_TYPE_TWO = 2; //自动
    const SETTLE_TYPE_THREE = 3; //外催扣款
    const SETTLE_TYPE_FOUR = 4; //自催扣款

    //对应新卡贷还款状态map
    //1:待处理,2:处理中,3:失败,4:成功
    public static $virement_status_map = [1,2,4,3];

    protected $table = 'ws_loan.loan_virement';

    /**
     * Description: 获取流水号
     * Author: Gxs
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     */
    public function relationPayOder()
    {
        return $this->hasOne('App\ModelTransfers\WsAccount\PayOrder', 'id', 'order_id')
            ->where([
                ['is_valid', self::IS_VALID],
                ['order_status', 2],
            ]);
    }

}